//
//  LXLTopIconBottomTitleButton.m
//  QA
//
//  Created by 李小龙 on 2017/6/7.
//  Copyright © 2017年 ZDQK. All rights reserved.
//

#import "LXLTopIconBottomTitleButton.h"

@implementation LXLTopIconBottomTitleButton

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
    [self setTitleEdgeInsets:UIEdgeInsetsMake(self.imageView.frame.size.height+2*self.titleLabel.bounds.size.height , -self.imageView.frame.size.width, 0.0, 0.0)];
    [self setImageEdgeInsets:UIEdgeInsetsMake(0, 0.5*self.titleLabel.bounds.size.width, 0, -0.5*self.titleLabel.bounds.size.width)];
}
*/
- (instancetype)init {
    self = [super init];
    if (self) {
        [self awakeFromNib];
    }
    return self;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    [self setTitleEdgeInsets:UIEdgeInsetsMake(self.imageView.frame.size.height+self.titleLabel.bounds.size.height , -self.imageView.frame.size.width, 0.0, 0.0)];
    [self setImageEdgeInsets:UIEdgeInsetsMake(-self.titleLabel.bounds.size.height, 0.5*self.titleLabel.bounds.size.width, 0, -0.5*self.titleLabel.bounds.size.width)];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    [self setTitleEdgeInsets:UIEdgeInsetsMake(self.imageView.frame.size.height+self.titleLabel.bounds.size.height , -self.imageView.frame.size.width, 0.0, 0.0)];
    [self setImageEdgeInsets:UIEdgeInsetsMake(-self.titleLabel.bounds.size.height, 0.5*self.titleLabel.bounds.size.width, 0, -0.5*self.titleLabel.bounds.size.width)];
}
@end
